import {
  Component, OnInit, Input, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef,
  AfterViewInit
} from '@angular/core';
import {GoodsCategory} from "@interface/index";




@Component({
  selector: 'seed-filter-item',
  templateUrl: './filter-item.component.html',
  styleUrls: ['./filter-item.component.scss'],
  encapsulation: ViewEncapsulation.None,
})
export class FilterItemComponent implements OnInit, AfterViewInit {
  public active = 0;
  public store: GoodsCategory;
  public finally = false;
  @Input() data;

  constructor(public cdr: ChangeDetectorRef) {
  }

  selectHandler(item, idx = 0) {
    this.active = idx;
    this.store = item;
  }

  /**
   * @description reset方法此component里面的数据成为初始化状态
   * @date 2017-08-18
   * @author 陈文豪
   */
  reset() {

    this.active = 0;
    this.store = null;
    this.cdr.detectChanges();
  }

  visibleHandler() {
    return (this.data.categoryList && this.data.categoryList.length > 0);
    /*|| (this.data.attributeList && this.data.attributeList.length>0)
     || (this.data.brandList && this.data.brandList.length>0);*/
  }


  /*  init(item,idx = 0){
   this.active = idx;
   this.store = item;
   }*/

  ngAfterViewInit () {
    // this.init();
  }

  ngOnInit() {

  }

}
